<?php
require_once(APPLICATION_PATH . '/../library/Exts/Services/Facebook.php');
class Exts_Services_Fb_Facebook {

	protected $_token;
	protected $_facebook;

	public function __construct( $appId, $appSecret ){
		
		$facebook = new Facebook(array(
				'appId' => $appId,
				'secret' => $appSecret,
				'cookie' => true
			));
		$this->_token = $facebook->getAccessToken();

		$likeID = $facebook->api(
			array( 'method' => 'fql.query', 'query' =>
			'SELECT uid,type FROM page_fan WHERE page_id =142008882519161 ' )
		);
		print_r($likeID);exit;
		return ;
		print_r( $result);exit;
		$this->_facebook = new FacebookRestClient($appId,$appSecret);

		$result = $fb->call_method('facebook.auth.getSession',
			array('auth_token' => $this->_token, 'generate_session_secret' => true)
		);
		print_r( $result);exit;
		//$this->_token = $facebook->getAccessToken();

		

	}

	public function getFriends(){
        $ch = curl_init();
        $url = 'https://graph.facebook.com/'.$albumid.'/photos?access_token='.$access_token;
        curl_setopt($ch, CURLOPT_URL, $url);
        curl_setopt($ch, CURLOPT_HEADER, false);
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
        curl_setopt($ch, CURLOPT_POST, true);
        curl_setopt($ch, CURLOPT_POSTFIELDS, $params);

        $this->setResponse( curl_exec($ch) );
        $this->setHeaders( curl_getinfo($ch) );
        $this->setErrorCode( curl_errno($ch) );
        $this->setErrorMessage( curl_error($ch) );
        curl_close($ch);
        return $this->build_response();
	}

	public function getToken(){
		return $this->_token;
	}

}